"""
删除前缀相同的照片
"""

import argparse
import os

parser = argparse.ArgumentParser(description="信息输入")
parser.add_argument('indir', type=str, help='输入文件夹名称')
args = parser.parse_args()


def delete_same_img(indir):
    prepaths = []
    for root, dirs, files in os.walk(indir):
        for file in files:
            path = os.path.join(root, file)
            prepath = path.split("_")[0]
            if prepath not in prepaths:
                print("没在里面", "----", prepath)
                prepaths.append(prepath)
            else:
                print("在里面", "----", prepath)
                os.remove(path)


if __name__ == '__main__':
    delete_same_img(args.indir)
